<?php $this->load->view('header');?>
<script type="text/javascript" src="<?php echo base_url();?>scripts/jwplayer.js"></script>
<?php if(!$user = $this->session->userdata('userdata')) $user = NULL;?> 

<script type="text/javascript">
var id_video = <?php echo json_encode($detail['id_video']);?>;
	$(document).ready(function(){
		//update_comment(id_video);
	});
</script>
</div>
<div id="content">
    
    <div id="sidebar_right">
    	<?php $this->load->view('right_sidebar', $right_sidebar); ?>
    </div>
    
   		<article class="sidebar_right">
        	<h2 class="blog_post_title"><?php echo $detail['judul'];?></h2>
            <span class="blog_post_info">Diposting oleh <?php echo $detail['username'];?> | <?php echo timestamp_to_date_time($detail['waktu_posting']); ?></span>
            <span class="blog_post_info_right"><?php echo count($komentars);?> komentar</span>
        	<center><?php echo show_youtube($detail['url']); ?></center>
            <p><?php echo $detail['deskripsi'];?></p>
        </article>
        
        <!--<article class="sidebar_right">
        	<div class="share_this_article">
            	<span>Share video</span>
                <ul>
                    <li><a href="#"><img src="<?php echo base_url();?>images/social_icons/facebook.png" alt="Facebook" /></a></li>
                    <li><a href="#"><img src="<?php echo base_url();?>images/social_icons/flickr.png" alt="Flickr" /></a></li>
                    <li><a href="#"><img src="<?php echo base_url();?>images/social_icons/linkedin.png" alt="Linkedin" /></a></li>
                    <li><a href="#"><img src="<?php echo base_url();?>images/social_icons/twitter.png" alt="Twitter" /></a></li>
                    <li><a href="#"><img src="<?php echo base_url();?>images/social_icons/youtube.png" alt="Youtube" /></a></li>
                </ul>
            </div>
        </article>-->
		
  		<article class="sidebar_right">
        	<div id="article_comments">
            	<div class="title">
                	<span>Kirim Komentar</span>
                </div>
				<div class="error">
					<img src="<?php echo base_url();?>images/site_icon/delete.png" class="response_img"/>
					Mohon maaf, komentar Anda gagal dikirim, silahkan ulangi kembali.
				</div>
				<div class="success">
					<img src="<?php echo base_url();?>images/site_icon/ok.png" class="response_img"/>
					Komentar Anda berhasil dikirim, terimakasih.
				</div>
		<?php if($user) {?>
				<form class="contact_form">
					<input type="hidden" id="id_video" value="<?php echo $detail['id_video'];?>" />
					<textarea style="width: 565px; height: 112px; resize:vertical;" id="isi_komentar"></textarea>
					<input type="submit" value="Kirim" id="kirim_komentar_video" />
				</form>
		<?php }else{ ?>
				<p>Jika ingin memberikan komentar, silahkan login terlebih dahulu.</p>
		<?php }?>
				<br />
			</div>
		</article>
		
        <article class="sidebar_right">
        	<div id="article_comments" class="list_comment">
            	<div class="title" id="title_list">
                	<span>Komentar</span>
                </div>
                <?php foreach($komentars as $komentar){?>
                <div class="comment">
                	<img src="<?php echo base_url()."images/user_avatars/".$komentar['id_user'].".jpg";?>" alt="" />
                    <span class="comment_title">Komentar dari <b><a href="<?php echo base_url()."users/index/".$komentar['id_user'];?>">
					<?php echo $komentar['comment_writer']; ?></a></b></span>
                    <span class="comment_title_right"><?php echo elapsed_time($komentar['waktu_posting']);?></span>
                    <p><?php echo $komentar['isi'];?></p>
                </div>
                <?php 
					} 
					if(!$komentars):
				?>				
                <p>Belum ada komentar untuk video ini.</p>
				<?php endif; ?>
            </div>
        </article>
        
	<div class="cleaner"></div>
    </div>
    <div class="cleaner"></div>
<?php $this->load->view('footer', $right_sidebar);?>